//JavaScript Framework 2.0 Code
try {
	Type.registerNamespace('com.yonyou.enterprise.StudentListController');
	com.yonyou.enterprise.StudentListController = function() {
		com.yonyou.enterprise.StudentListController.initializeBase(this);
		this.initialize();
	}
	function com$yonyou$enterprise$StudentListController$initialize() {
		//you can programing by $ctx API
		//get the context data through $ctx.get()
		//set the context data through $ctx.push(json)
		//set the field of the context through $ctx.put(fieldName, fieldValue)
		//get the parameter of the context through $ctx.param(parameterName)
		//Demo Code:
		//    var str = $ctx.getString();      //获取当前Context对应的字符串
		//    alert($ctx.getString())          //alert当前Context对应的字符串
		//    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
		//    json["x"] = "a";        //为当前json增加字段
		//    json["y"] = [];           //为当前json增加数组
		//    $ctx.push(json);            //设置context，并自动调用数据绑定
		//
		//    put方法需手动调用databind()
		//    var x = $ctx.get("x");    //获取x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
		//    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
		//    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
		//    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组

		//your initialize code below...

	}

	function com$yonyou$enterprise$StudentListController$evaljs(js) {
		eval(js)
	}

	function com$yonyou$enterprise$StudentListController$button1_onclick(sender, args) {
		$view.open({
			"viewid" : "com.yonyou.enterprise.StudentDetail", //目标页面（首字母大写）全名，
			"isKeep" : "false",
			"flag" : "add"
		});

	}

	function loadData(sender, args) {
		$service.callAction({
			"viewid" : "com.yyuap.enterprise.service.EnterpriseController", //后台Controller(带包名)的类名
			"action" : "loadData", //后台Controller的方法名,
			"condition" : "", //自定义参数
			"callback" : "myCallBack()", //请求成功后回调js方法
			"error" : "myErrCallBack()"//请求失败回调的js方法
		})

	}

	function myCallBack() {
		var flag = $ctx.getString("flag");
		var des = $ctx.getString("des");

		if (flag == "success") {
			var stuList = $stringToJSON($ctx.getString("stuList"));
			
			var json = {
				"stuList" : stuList
			};
			$ctx.push(json);
		} else {
			$alert(des);
		}
	}

	function myErrCallBack() {
		alert("加载数据失败");
	}

	function search(sender, args) {
		var keyValue = $id("search0").get("value");
		$service.callAction({
			"viewid" : "com.yyuap.enterprise.service.EnterpriseController", //后台Controller(带包名)的类名
			"action" : "loadData", //后台Controller的方法名,
			"condition" : keyValue, //自定义参数
			"callback" : "myCallBack()", //请求成功后回调js方法
			"error" : "myErrCallBack()"//请求失败回调的js方法
		})
	}

	function openDetail(sender, args) {
		var row = $id("listviewdefine0").get("row");
		$view.open({
			"viewid" : "com.yonyou.enterprise.StudentDetail", //目标页面（首字母大写）全名，
			"isKeep" : "false",
			"row" : row,
			"flag" : "edit"
		});
	}

	function delData(sender, args) {
		var row = $id("listviewdefine0").get("row");
		var id = $stringToJSON(row).id;

		$service.callAction({
			"viewid" : "com.yyuap.enterprise.service.EnterpriseController", //后台Controller(带包名)的类名
			"action" : "delData", //后台Controller的方法名,
			"condition" : id, //自定义参数
			"callback" : "delCallBack()", //请求成功后回调js方法
			"error" : "delErrCallBack()"//请求失败回调的js方法
		})

	}

	function delCallBack() {
		var flag = $ctx.getString("flag");
		var des = $ctx.getString("des");

		if (flag == "success") {
			loadData();
		} else {
			$alert(des);
		}

	}

	function delErrCallBack() {
		$alert("删除数据失败");
	}

	function com$yonyou$enterprise$StudentListController$button0_onclick(sender, args) {
		$view.open({
			"viewid" : "com.yonyou.enterprise.Loginconset", //目标页面（首字母大写）全名，
			"isKeep" : "false"
		});
	}


	com.yonyou.enterprise.StudentListController.prototype = {
		button0_onclick : com$yonyou$enterprise$StudentListController$button0_onclick,
		button1_onclick : com$yonyou$enterprise$StudentListController$button1_onclick,
		initialize : com$yonyou$enterprise$StudentListController$initialize,
		evaljs : com$yonyou$enterprise$StudentListController$evaljs
	};
	com.yonyou.enterprise.StudentListController.registerClass('com.yonyou.enterprise.StudentListController', UMP.UI.Mvc.Controller);
} catch(e) {
	$e(e);
}
